package com.roam.cofig;

import com.roam.interceptor.LoginCheckInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    /*
    * 注入LoginCheckInterceptor类
    * */
    @Autowired
    private LoginCheckInterceptor loginCheckInterceptor;


    /*
    * 注册拦截器
    * */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //拦截/user页面，判断登录情况
        registry.addInterceptor(loginCheckInterceptor).addPathPatterns("/userMessage/get/**");
    }
}
